package com.zy.ems.service;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zy.ems.common.base.BaseDao;
import com.zy.ems.common.base.BaseService;
import com.zy.ems.dao.MemberDao;
import com.zy.ems.model.MemberEntity;
import com.zy.ems.utils.util.MemberUtil;

@Service
@Transactional
public class MemberService extends BaseService<MemberEntity, Integer> {
	@Autowired
	private MemberDao memberDao;

	public MemberEntity login(String userName, String userPassword) {
		MemberEntity memberEntity = this.memberDao.findMemberByUserName(userName);

		if (memberEntity == null) {
			return null;
		}

		userPassword = MemberUtil.getMemberPasswordWithSalt(userPassword);

		if (memberEntity.getPassword().equals(userPassword)) {
			return memberEntity;
		}

		return null;
	}

	@Override
	public BaseDao<MemberEntity, Integer> getEntityDao() {
		return this.memberDao;
	}

	/**
	 * 
	 */
	public boolean register(Map<String, String> param) {
		return false;
	}

}
